'''
    9*9乘法表
    H为列，B为行
    使用for in 和while两种循环语句
    使用.format 输出
'''
for H in range(1,10):
    while H <= 9:
        for B in range(1,H+1):
            print('{}*{}={:<4}'.format(H, B, H * B),end=' ')
        if H <= B:
            print('')
        # if H * B <= 81:
            break

for H in range(9,0,-1):
    while H <= 9:
        for B in range(1,H+1):
            print('{}*{}={:<4}'.format(H, B, H * B),end=' ')
        if H <= B:
            print('')
        # if H * B <= 81:
            break

print('='*80)

H = 1
while H <=9:
    for B in range(1,H+1):
        print('{}*{}={:<4}'.format(H, B, H * B), end=' ')
    print('')
    H = H + 1

H = 9
while 0 < H <= 9:
    for B in range(1,H+1):
        print('{}*{}={:<4}'.format(H, B, H * B), end=' ')
    print('')
    H = H - 1

print('='*80)

H = 1
while H <= 9:
    for B in range(H,0,-1):
        print('{}*{}={:<4}'.format(H, B, H * B), end=' ')
    print('')
    H = H + 1

H = 9
while 0 < H <= 9:
    for B in range(H,0,-1):
        print('{}*{}={:<4}'.format(H, B, H * B), end=' ')
    print('')
    H = H - 1

print('='*80)

H = 1
while H <= 9:
    B = 1
    while B <= H:
        print('{}*{}={:<4}'.format(H,B,H*B),end=' ')
        B = B + 1
    print('')
    H = H + 1

H = 9
while 0 < H <= 10:
    B = 1
    while B <= H :
        print('{}*{}={:<4}'.format(H,B,H*B),end=' ')
        B = B + 1
    print('')
    H = H - 1

print('='*80)

for H in range(1,10):
    for B in range(1,10):
        if H <= B:
            print('{}*{}={:<4}'.format(H,B,H*B),end=' ')
        else:
            print(end=' '*9)
    print(' ')

for H in range(9,0,-1):
    for B in range(1,10):
        if H <= B:
            print('{}*{}={:<4}'.format(H,B,H*B),end=' ')
        else:
            print(end=' '*9)
    print(' ')

print('='*80)

H = 1
while H <= 9:
    B = 1
    while B <= 9:
        if B >= H:
            print('{}*{}={:<4}'.format(H,B,H*B),end=' ')
        else:
            print(end=' '*9)
        B = B + 1
    print('')
    H = H + 1

H = 9
while 0 < H <= 10:
    B = 1
    while B <= 9 :
        if B >= H:
            print('{}*{}={:<4}'.format(H,B,H*B),end=' ')
        else:
            print(end=' '*9)
        B = B + 1
    print('')
    H = H - 1

print('='*80)

H = 1
while H <=9:
    for B in range(1,10):
        if H <= B:
            print('{}*{}={:<4}'.format(H, B, H * B), end=' ')
        if H > B:
            print(end=' '*9)
    print('')
    H = H + 1

H = 9
while 0 < H <= 9:
    for B in range(1,10):
        if H <= B:
            print('{}*{}={:<4}'.format(H, B, H * B), end=' ')
        if H > B:
            print(end=' '*9)
    print('')
    H = H - 1

print('='*80)

for H in range(1,10):
    while H <= 9:
        for B in range(1,10):
            if H <= B:
                print('{}*{}={:<4}'.format(H, B, H * B),end=' ')
            else:
                print(end=' '*9)
        if H <= B:
            print('')
        if H * B <= 81:
            break

for H in range(9,0,-1):
    while H <= 9:
        for B in range(1,10):
            if H <= B:
                print('{}*{}={:<4}'.format(H, B, H * B),end=' ')
            else:
                print(end=' ' * 9)
        if H <= B:
            print('')
        if H * B <= 81:
            break


